Fixed the game would freeze when the mouse moving over the window.#46
Open
chansey97 wants to merge 1 commit intoivanperez-keera:developfrom
Open
Fixed the game would freeze when the mouse moving over the window.#46chansey97 wants to merge 1 commit intoivanperez-keera:developfrom
chansey97 wants to merge 1 commit intoivanperez-keera:developfrom
Conversation
…r the window. Phenomenon: After executing spaceInvaders.exe, If you moving the mouse over the window, the game freezes! Root cause: When Yampa's sensing action takes window input, if the input is a `HGL.MouseMove` event, it calls `mmFilter` to consume all subsequent "redundant" `HGL.MouseMove` events. If there are several hundred `HGL.MouseMove` events, `mmFilter` will be recursively called several hundreds of times. The`mmFilter` further calls `gwi win` to take events, and `gwi win` calls `HGL.getWindowTick win` to yield the time slices to ensure that the thread acturally receiving WM events gets a chance to work. This leads to a problem: Since `HGL.getWindowTick win` is a blocking operation (i.e. waiting for a tickRate time), if there are 100 subsequent `HGL.MouseMove`, it will wait for "100 x tickRate time", which is unacceptable. Moreover, during this waiting period, there might be further mouse move events generated! This patch fixed the issue by placing `HGL.getWindowTick win` at the beginning of a frame, i.e. at the entry point of `getTimeInput`, rather than inside `gwi win`. Related issue: ivanperez-keera#44
This was referenced Mar 7, 2024
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Phenomenon:
After executing spaceInvaders.exe, if you moving the mouse over the window, the game freezes!
Root cause:
When Yampa's sensing action takes window inputs, if the input is a
HGL.MouseMoveevent, it will callmmFilterto consume all subsequent "redundant"HGL.MouseMoveevents. If there are several hundredHGL.MouseMoveevents,mmFilterwill be recursively called several hundreds of times.The
mmFilterfurther callsgwi winto take events, andgwi wincallsHGL.getWindowTick winto yield some time slices to ensure that the thread actually receiving WM events gets a chance to work.This leads to a problem:
Since
HGL.getWindowTick winis a blocking operation (i.e. waiting for a tickRate time), if there are 100 subsequentHGL.MouseMove, it will wait for "100 x tickRate time", which is unacceptable. Moreover, during this waiting period, there might be further mouse move events generated!This patch fixed the issue by placing
HGL.getWindowTick winat the beginning of a frame, i.e. at the entry point ofgetTimeInput, rather than insidegwi win.Related issue: #44
P.s. This PR is the same as the old one #45. I have to open a new PR because the old PR #45 used
developbranch, which is difficult to maintain (rename branch close the old PR automatically).